package com.vcc.web.core.queue.batch.close.model;

import lombok.*;

import jakarta.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;

@Data
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class CloseQueueDto implements Delayed {

    private Long time;

    private String cardNumber;

    private String orderId;

    private Integer index;

    private Integer targetIndex;


    @Override
    public long getDelay(@NotNull TimeUnit unit) {
        return unit.convert(time - System.currentTimeMillis(), TimeUnit.MILLISECONDS);
    }

    @Override
    public int compareTo(@NotNull Delayed o) {
        return Long.compare(getDelay(TimeUnit.MILLISECONDS), o.getDelay(TimeUnit.MILLISECONDS));
    }
}
